package test1.impl;

import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import test1.BookDao;
import test1.BookService;

import java.util.List;

//InitializingBean, DisposableBean两个接口分别提供了初始化bean，摧毁bean时候会回调的函数

public class BookServiceImpl implements BookService, InitializingBean, DisposableBean {

    //使用spring的ioc注入
    private int id;
    private String name;
    private List<String> relations;
    private BookDao bookDao;


    public void setId(int id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setRelations(List<String> relations) {
        this.relations = relations;
    }

    public void setBookDao(BookDao bookDao) {
        this.bookDao = bookDao;
    }

    public void save() {
        System.out.println("bookService run---");
        bookDao.search();
    }


    public void destroy() throws Exception {
        System.out.println("BookService destory!");
    }

    public void afterPropertiesSet() throws Exception {
        System.out.println("BookService init!");
    }
}
